package com.chagee.channel.server.controller.hik;

import com.chagee.base.utils.HttpResponse;
import com.chagee.base.utils.HttpResponseUtil;
import com.chagee.channel.api.request.hik.HikCaptureReqBO;
import com.chagee.channel.api.request.hik.HikStoreCameraReqBO;
import com.chagee.channel.api.response.hik.HikAccessTokenRespBO;
import com.chagee.channel.api.response.hik.HikCaptureRespBO;
import com.chagee.channel.api.response.hik.HikEzvizAccountInfoRespBO;
import com.chagee.channel.api.response.hik.HikStoreCameraRespBO;
import com.chagee.channel.api.response.hik.HikStoreInfoRespBO;
import com.chagee.channel.server.service.third.HikThirdService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 巡检全球化V1.2.4二期——海康云眸接口封装
 *
 * @author kunpeng.zhang
 * @date 2024/09/29
 */
@Slf4j
@RestController
@RequestMapping("/inspection/hik")
public class HikThirdController {

    @Resource
    private HikThirdService hikThirdService;

    /**
     * 授权凭证获取
     *
     * @return
     */
    @ResponseBody
    @PostMapping("/access/token")
    public HttpResponse<HikAccessTokenRespBO> getHikAccessToken() {
        return HttpResponseUtil.success(hikThirdService.getHikAccessToken());
    }

    /**
     * 获取WEB视频控件token
     *
     * @return
     */
    @ResponseBody
    @PostMapping("/video/token")
    public HttpResponse<HikAccessTokenRespBO> getVideoToken() {
        return HttpResponseUtil.success(hikThirdService.getVideoToken());
    }

    /**
     * 取流认证token获取
     *
     * @return
     */
    @ResponseBody
    @PostMapping("/ezviz/account/info")
    public HttpResponse<HikEzvizAccountInfoRespBO> getEzvizAccountInfo() {
        return HttpResponseUtil.success(hikThirdService.getEzvizAccountInfo());
    }

    /**
     * 远程抓图
     *
     * @param reqBO
     * @return
     */
    @ResponseBody
    @PostMapping("/basic/channels/actions/capture")
    public HttpResponse<HikCaptureRespBO> basicCapture(@RequestBody HikCaptureReqBO reqBO) {
        return HttpResponseUtil.success(hikThirdService.basicCapture(reqBO));
    }

    /**
     * 设备抓图
     *
     * @param reqBO
     * @return
     */
    @ResponseBody
    @PostMapping("/customization/capture")
    public HttpResponse<HikCaptureRespBO> customizationCapture(@RequestBody HikCaptureReqBO reqBO) {
        return HttpResponseUtil.success(hikThirdService.customizationCapture(reqBO));
    }

    /**
     * 通过门店编号查询设备通道列表
     *
     * @param reqBO
     * @return
     */
    @ResponseBody
    @PostMapping("/store/cameraList")
    public HttpResponse<HikStoreCameraRespBO> getStoreCameraList(@RequestBody HikStoreCameraReqBO reqBO) {
        return HttpResponseUtil.success(hikThirdService.getStoreCameraList(reqBO));
    }

    /**
     * 获取门店列表
     *
     * @param reqBO
     * @return
     */
    @ResponseBody
    @PostMapping("/store/page")
    public HttpResponse<HikStoreInfoRespBO> getStoreInfoPage(@RequestBody HikStoreCameraReqBO reqBO) {
        return HttpResponseUtil.success(hikThirdService.getStoreInfoPage(reqBO));
    }

}